
class P10235 {

	static boolean[] primes = new boolean[1000000];

	public static void main(String[] args) {
		createPrimes();
		
		String line = readLn();
		while (line != null) {
			int n = Integer.parseInt(line);
			if (!primes[n]) {
				System.out.println(n + " is not prime.");
			} else {
				int nReverse = reverseIt(n);
				if (primes[nReverse] && nReverse != n) {
					System.out.println(n + " is emirp.");
				} else {
					System.out.println(n + " is prime.");
				}
			}
			
			line = readLn();
		}
	}
	
	
	
	private static int reverseIt(int n) {
		String st = "" + n;
		StringBuffer reverseSt = new StringBuffer(); 
		for (int k = st.length() - 1; k >= 0 ; k--) {
			reverseSt.append(st.charAt(k));
		}
		return Integer.parseInt(reverseSt.toString());
	}



	static void createPrimes() {
	   int i, j;

	   for(i = 0; i < 1000000; i++) {
	      primes[i] = false;
	   }

	   primes[2] = true;
	   primes[3] = true;

	   for(i = 5; i < 1000000; i+=2) {
	       for(j = 3; j*j <=i ; j+=2)
	           if(i % j == 0) break;
	       if(i % j != 0 ) primes[i] = true;
	   }
	}
	
	
	   static String readLn() {
	       String newLine = System.getProperty("line.separator");
	       StringBuffer buffer = new StringBuffer();
	       int car = -1;
	       try {
	           car = System.in.read();
	           while ((car > 0) && (car != newLine.charAt(0))) {
	               buffer.append((char)car);
	               car = System.in.read();
	           }
	           if (car == newLine.charAt(0))
	           System.in.skip(newLine.length() - 1);
	       } catch (java.io.IOException e) { return (null);}
	       if ((car < 0) && (buffer.length() == 0)) return (null);
	       return (buffer.toString()).trim();
	   }
	
}
